package com.chatdating.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chatdating.entity.Post;
import com.chatdating.entity.dto.AdminPostDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface PostMapper extends BaseMapper<Post> {
    @Select("select * from posts")
    List<Post> postListAll();
    @Select("select * from posts where id = #{id}")
    List<Post> findById(Long id);

    List<AdminPostDto> selectPostBy(@Param("username")String uname, @Param("id")Integer id);

    List<AdminPostDto> delPostList(@Param("username")String uname, @Param("id")Integer id);
    @Update("update posts set deleted = 1 where id = #{id}")
    void adminRemoveById(int id);
    @Update("update posts set deleted = 0 where id = #{id}")
    void adminRecoverPostById(int id);
    @Select("select * from posts where id = #{id}")
    Post selectPostById(Long id);
}
